package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.NursingProjectMapper;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NursingProjectServiceImpl implements NursingProjectService {
    @Autowired
    private NursingProjectMapper nursingProjectMapper;

    @Override
    public PageResponse<NursingProjectVo> selectByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<NursingProject> nursingProjects = nursingProjectMapper.selectByPage(name, status);
        PageResponse<NursingProjectVo> projectVoPageResponse = PageResponse.of(nursingProjects, NursingProjectVo.class);
        return projectVoPageResponse;
    }

    /**
     * 新增护理项目
     * @param nursingProjectDTO 护理项目数据传输对象
     */
    @Override

    public void add(NursingProjectDto nursingProjectDTO) {
        NursingProject nursingProject = BeanUtil.copyProperties(nursingProjectDTO, NursingProject.class);
        nursingProjectMapper.insert(nursingProject);
    }
    /**
     * 根据项目ID获取护理项目详情的视图对象。
     *
     * @param id 护理项目的唯一标识符。
     * @return NursingProjectVo 对象，包含护理项目的详细信息。当前实现中返回null，表示未实现或不提供具体实现。
     */
    @Override
    public NursingProjectVo getById(Long id) {
       NursingProject nursingProject= nursingProjectMapper.getById(id);
        NursingProjectVo nursingProjectVo = BeanUtil.copyProperties(nursingProject, NursingProjectVo.class);
        return nursingProjectVo;
    }
}
